package com.yuw.homework4;

public class HourlyEmployee extends ColaEmployee {
    // 属性
    private double salaryPerHour; // 每小时薪资
    private double totalHoursPermonth; // 每月工作小时数
    // 行为

    public HourlyEmployee(String empName, int empBirthMonth, double salaryPerHour, double totalHoursPermonth) {
        super(empName, empBirthMonth);
        this.salaryPerHour = salaryPerHour;
        this.totalHoursPermonth = totalHoursPermonth;
    }

    @Override
    public double getSalary(int month) {
        // 按小时计算所有小时的基本工资
        double salarySum = salaryPerHour * totalHoursPermonth;
        // 再计算超过160小时的 0.5 倍工资
        salarySum += (totalHoursPermonth - 160) > 0 ? (totalHoursPermonth - 160) * 0.5 * salaryPerHour : 0;
        return salarySum + super.getSalary(month);
    }
}
